<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Environment</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Environment.html#getFullArgs"><span class="hs-identifier">getFullArgs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.html"><span class="hs-identifier">Foreign</span></a></span><span>
</span><span id="line-8"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.html"><span class="hs-identifier">Foreign.C</span></a></span><span>
</span><span id="line-9"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier">fromIntegral</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.html"><span class="hs-identifier">GHC.IO.Encoding</span></a></span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Foreign.html"><span class="hs-identifier">GHC.Foreign</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">GHC</span></span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span class="hs-cpp"># if defined(i386_HOST_ARCH)
</span><span class="hs-cpp">#  define WINDOWS_CCONV stdcall
</span><span class="hs-cpp"># elif defined(x86_64_HOST_ARCH)
</span><span class="hs-cpp">#  define WINDOWS_CCONV ccall
</span><span class="hs-cpp"># else
</span><span class="hs-cpp">#  error Unknown mingw32 arch
</span><span class="hs-cpp"># endif
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- | Computation 'getFullArgs' is the &quot;raw&quot; version of</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- 'System.Environment.getArgs', similar to @argv@ in other languages. It</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- returns a list of the program's command line arguments, starting with the</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- program name, and including those normally eaten by the RTS (+RTS ... -RTS).</span><span>
</span><span id="line-28"></span><span class="annot"><a href="GHC.Environment.html#getFullArgs"><span class="hs-identifier hs-type">getFullArgs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-29"></span><span id="getFullArgs"><span class="annot"><span class="annottext">getFullArgs :: IO [String]
</span><a href="GHC.Environment.html#getFullArgs"><span class="hs-identifier hs-var hs-var">getFullArgs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-30"></span><span>  </span><span class="annot"><span class="annottext">(Ptr CInt -&gt; IO [String]) -&gt; IO [String]
forall a b. Storable a =&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Alloc.html#alloca"><span class="hs-identifier hs-var">alloca</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr CInt -&gt; IO [String]) -&gt; IO [String])
-&gt; (Ptr CInt -&gt; IO [String]) -&gt; IO [String]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679563006"><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679563006"><span class="hs-identifier hs-var">p_argc</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-31"></span><span>    </span><span class="annot"><span class="annottext">(Ptr (Ptr CString) -&gt; IO [String]) -&gt; IO [String]
forall a b. Storable a =&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Alloc.html#alloca"><span class="hs-identifier hs-var">alloca</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr (Ptr CString) -&gt; IO [String]) -&gt; IO [String])
-&gt; (Ptr (Ptr CString) -&gt; IO [String]) -&gt; IO [String]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679563005"><span class="annot"><span class="annottext">Ptr (Ptr CString)
</span><a href="#local-6989586621679563005"><span class="hs-identifier hs-var">p_argv</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><span class="annottext">Ptr CInt -&gt; Ptr (Ptr CString) -&gt; IO ()
</span><a href="GHC.Environment.html#getFullProgArgv"><span class="hs-identifier hs-var">getFullProgArgv</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679563006"><span class="hs-identifier hs-var">p_argc</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr CString)
</span><a href="#local-6989586621679563005"><span class="hs-identifier hs-var">p_argv</span></a></span><span>
</span><span id="line-33"></span><span>        </span><span id="local-6989586621679563003"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679563003"><span class="hs-identifier hs-var">p</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(CInt -&gt; Int) -&gt; IO CInt -&gt; IO Int
forall (m :: * -&gt; *) a1 r. Monad m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r
</span><a href="GHC.Base.html#liftM"><span class="hs-operator hs-var">`liftM`</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt -&gt; IO CInt
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CInt
</span><a href="#local-6989586621679563006"><span class="hs-identifier hs-var">p_argc</span></a></span><span>
</span><span id="line-34"></span><span>        </span><span id="local-6989586621679563000"><span class="annot"><span class="annottext">Ptr CString
</span><a href="#local-6989586621679563000"><span class="hs-identifier hs-var">argv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr CString) -&gt; IO (Ptr CString)
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr CString)
</span><a href="#local-6989586621679563005"><span class="hs-identifier hs-var">p_argv</span></a></span><span>
</span><span id="line-35"></span><span>        </span><span id="local-6989586621679562999"><span class="annot"><span class="annottext">TextEncoding
</span><a href="#local-6989586621679562999"><span class="hs-identifier hs-var">enc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO TextEncoding
</span><a href="GHC.IO.Encoding.html#argvEncoding"><span class="hs-identifier hs-var">argvEncoding</span></a></span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><span class="annottext">Int -&gt; Ptr CString -&gt; IO [CString]
forall a. Storable a =&gt; Int -&gt; Ptr a -&gt; IO [a]
</span><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier hs-var">peekArray</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679563003"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CString
</span><a href="#local-6989586621679563000"><span class="hs-identifier hs-var">argv</span></a></span><span> </span><span class="annot"><span class="annottext">IO [CString] -&gt; ([CString] -&gt; IO [String]) -&gt; IO [String]
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">(CString -&gt; IO String) -&gt; [CString] -&gt; IO [String]
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Base.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TextEncoding -&gt; CString -&gt; IO String
</span><a href="GHC.Foreign.html#peekCString"><span class="hs-identifier hs-var">GHC.peekCString</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="#local-6989586621679562999"><span class="hs-identifier hs-var">enc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;getFullProgArgv&quot;</span></span><span>
</span><span id="line-39"></span><span>    </span><span id="getFullProgArgv"><span class="annot"><a href="GHC.Environment.html#getFullProgArgv"><span class="hs-identifier hs-var">getFullProgArgv</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="Foreign.C.String.html#CString"><span class="hs-identifier hs-type">CString</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-40"></span></pre></body></html>